how to solve using beta function